﻿using CChaunce.Dapper.Filters.Query;
using Chaunce.Dapper.Expressions;
using DapperExtensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace Chaunce.Dapper.Filters.Query
{
    public class DapperQueryFilterExecuter: IDapperQueryFilterExecuter
    {
        public static readonly DapperQueryFilterExecuter Instance = new DapperQueryFilterExecuter();
        
        public DapperQueryFilterExecuter()
        {
            
        }

        public IPredicate ExecuteFilter<TEntity, TPrimaryKey>(Expression<Func<TEntity, bool>> predicate) where TEntity : class
        {
            
            IPredicate pg = predicate.ToPredicateGroup<TEntity, TPrimaryKey>();
            return pg;
        }

        public PredicateGroup ExecuteFilter<TEntity, TPrimaryKey>() where TEntity : class
        {
            var groups = new PredicateGroup
            {
                Operator = GroupOperator.And,
                Predicates = new List<IPredicate>()
            };
            return groups;
        }
    }
}
